﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using FRMS.DAL;
using System.IO;

namespace FRMS.BUS
{
    public class HCNetBUS
    {
        private CHCNetSDK.NET_DVR_ACS_WORK_STATUS_V50 m_struAcsWorkStatus = new CHCNetSDK.NET_DVR_ACS_WORK_STATUS_V50();
        private CHCNetSDK.MSGCallBack m_falarmData = null;
        //private CHCNetSDK.MSGCallBack_V31 m_falarmData_V31 = null;
        public CHCNetSDK.NET_DVR_DEVICEINFO_V30 m_struDeviceInfo;

        /// <summary>
        /// 海康SDK初始化
        /// </summary>
        public void NET_DVR_Init()
        {
            bool m_bInitSDK = CHCNetSDK.NET_DVR_Init();
            if (m_bInitSDK == false)
            {
                //初始化失败，错误内容记录日志
            }
            else
            {
                m_struAcsWorkStatus.Init();
                //FirstAuto = 1;
                CHCNetSDK.NET_DVR_SetLogToFile(3, "C:\\SdkLog\\", true);
            }
            uint dwSDKVersion = CHCNetSDK.NET_DVR_GetSDKBuildVersion();
            string sVersion = string.Format("{0}.{1}.{2}.{3}", (0xff000000 & dwSDKVersion) >> 24, (0x00ff0000 & dwSDKVersion) >> 16,
               (0x0000ff00 & dwSDKVersion) >> 8, (0x000000ff & dwSDKVersion));
            //labelSDKVersion.Text = "HCNetSDK V" + sVersion;
        }
        /// <summary>
        /// 设备注册启动
        /// </summary>
        /// <param name="m_lUserID"></param>
        /// <returns></returns>
        public bool Devconnectstart(int Eid, int m_UserID, string DeviceIP)
        {
            try
            {
                bool bl;
                DeviceDAL Ddal = new DeviceDAL();
                DeviceStateRecord Rdal = new DeviceStateRecord();
                if (m_UserID < 0)//设备未注册
                {//未注册
                    m_UserID = DevicesConnect(DeviceIP);
                    if (m_UserID < 0)
                    {
                        bl = false;
                    }
                    else
                    {
                        bl = true;
                        //add devicestaterecord--->上线
                        Rdal.AddDeviceStateRecord(Eid, "上线");
                    }
                    //update devicestate

                    Ddal.UpdateDevicestate(Eid, m_UserID);//设置设备在线或离线bl=true为在线
                }
                else
                {
                    //m_struAcsWorkStatus.Init();
                    bl = GetAcsWorkStatus(m_UserID, ref m_struAcsWorkStatus);
                    if (bl == false)
                    {   //重新注册设备
                        m_UserID = DevicesConnect(DeviceIP);
                        if (m_UserID < 0)
                        {
                            bl = false;
                            Ddal.UpdateDevicestate(Eid, -1);//设置设备离线
                            Rdal.AddDeviceStateRecord(Eid, "离线");
                        }
                        else
                        {
                            bl = true;
                            //add devicestaterecord--->上线
                            Ddal.UpdateDevicestate(Eid, m_UserID);//设置设备在线或离线bl=true为在线
                            Rdal.AddDeviceStateRecord(Eid, "上线");
                        }




                    }
                }
                return bl;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        /// <summary>
        /// 设备注册
        /// </summary>
        /// <param name="DevicesIP"></param>
        /// <returns></returns>
        public int DevicesConnect(string DevicesIP)
        {
            try
            {
                //登录设备 Login the device
                //string DVRIPAddress = "172.16.1.200";
                //Int16 DVRPortNumber = 8000;
                //string DVRUserName = "admin";
                //string DVRPassword = "admin123456";
                CHCNetSDK.NET_DVR_USER_LOGIN_INFO struLoginInfo = new CHCNetSDK.NET_DVR_USER_LOGIN_INFO();
                CHCNetSDK.NET_DVR_DEVICEINFO_V40 struDeviceInfoV40 = new CHCNetSDK.NET_DVR_DEVICEINFO_V40();
                //int lUserID = -1;

                //////struLoginInfo.bUseAsynLogin = false;
                //struLoginInfo.cbLoginResult = new CHCNetSDK.LoginResultCallBack(AsynLoginMsgCallback);
                //////struLoginInfo.byLoginMode = 2;
                struLoginInfo.sUserName = "admin";
                struLoginInfo.sPassword = "admin123456";
                struLoginInfo.sDeviceAddress = DevicesIP;//后期用DevicesIP传入值代替
                struLoginInfo.wPort = 8000;
                int m_lUserID = CHCNetSDK.NET_DVR_Login_V40(ref struLoginInfo, ref struDeviceInfoV40);
                //登录设备 Login the device
                //int m_lUserID = CHCNetSDK.NET_DVR_Login_V30(struLoginInfo.sDeviceAddress, struLoginInfo.wPort, struLoginInfo.sUserName, struLoginInfo.sPassword, ref m_struDeviceInfo);
                //////////DevCfgGet(m_lUserID);
                //设置报警回调函数，刷卡等事件都会触发报警回调函数 
                //设置报警回调函数

                CHCNetSDK.NET_DVR_SETUPALARM_PARAM struSetupAlarmParam = new CHCNetSDK.NET_DVR_SETUPALARM_PARAM();
                struSetupAlarmParam.dwSize = (uint)Marshal.SizeOf(struSetupAlarmParam);
                struSetupAlarmParam.byLevel = 1;
                struSetupAlarmParam.byAlarmInfoType = 1;
                struSetupAlarmParam.byDeployType = 1;//设置实时事件
                int lHandle = CHCNetSDK.NET_DVR_SetupAlarmChan_V41(m_lUserID, ref struSetupAlarmParam);// 启动布防

                m_falarmData = new CHCNetSDK.MSGCallBack(MsgCallback);
                if (CHCNetSDK.NET_DVR_SetDVRMessageCallBack_V50(0, m_falarmData, IntPtr.Zero))
                {
                    //MessageBox.Show("NET_DVR_SetDVRMessageCallBack_V50 succ", "succ", MessageBoxButtons.OK);
                }
                else
                {
                    //MessageBox.Show("NET_DVR_SetDVRMessageCallBack_V50 fail", "operation fail", MessageBoxButtons.OK);
                }


                return m_lUserID;
            }
            catch (Exception ex)
            {
                return -1;
            }

        }
        //void DevCfgGet(int m_lUserID)
        //{
        //    //设置设备时间
        //    DevicesGoto DG = new DevicesGoto();//类的实例化
        //    bool aa = DG.DevicesTimeSet(m_lUserID);
        //    //DevVersion[m_lUserID] = DG.btnDevCfgGet(m_lUserID);//设备版本号
        //    string[] DevNetBruf = DG.btnNetCfgGet(m_lUserID);//获取设备网络参数
        //    //DevNetBrufD[] DevNetBrufData = new DevNetBrufD[100];
        //    ////DevNetBrufData[m_lUserID].dev_vision = DG.btnDevCfgGet(m_lUserID);//设备版本号
        //    ////DevNetBrufData[m_lUserID].dev_ip = DevNetBruf[2];//设备ip
        //    ////DevNetBrufData[m_lUserID].dev_mask = DevNetBruf[3];//设备mask
        //    ////DevNetBrufData[m_lUserID].dev_gateway = DevNetBruf[4];//设备gateway
        //    ////DevNetBrufData[m_lUserID].dev_dns = DevNetBruf[5];//设备dns
        //    //更新数据库的设备参数信息
        //    //Database DB = new Database();
        //    string mysqlstr = "update dev_inf set Dev_version='" + DG.btnDevCfgGet(m_lUserID)
        //        + "' ,Dev_mask='" + DevNetBruf[3] + "',Dev_gateway='"
        //        + DevNetBruf[4] + "',Dev_dns='" + DevNetBruf[5] + "' where m_lUserID='" + m_lUserID + "'";

        //    DB.UpdateTableData(mysqlstr);
        //}
        private void MsgCallback(int lCommand, ref CHCNetSDK.NET_DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser)
        {
            switch (lCommand)
            {
                case CHCNetSDK.COMM_ALARM_ACS:
                    ProcessCommAlarmACS(ref pAlarmer, pAlarmInfo, dwBufLen, pUser);
                    break;
                default:
                    break;
            }
        }

        private void ProcessCommAlarmACS(ref CHCNetSDK.NET_DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser)
        {
            try
            {
                CHCNetSDK.NET_DVR_ACS_ALARM_INFO struAcsAlarmInfo = new CHCNetSDK.NET_DVR_ACS_ALARM_INFO();
                struAcsAlarmInfo = (CHCNetSDK.NET_DVR_ACS_ALARM_INFO)Marshal.PtrToStructure(pAlarmInfo, typeof(CHCNetSDK.NET_DVR_ACS_ALARM_INFO));
                CHCNetSDK.NET_DVR_LOG_V30 struFileInfo = new CHCNetSDK.NET_DVR_LOG_V30();
                struFileInfo.dwMajorType = struAcsAlarmInfo.dwMajor;
                struFileInfo.dwMinorType = struAcsAlarmInfo.dwMinor;
                char[] csTmp = new char[256];

                if (CHCNetSDK.MAJOR_ALARM == struFileInfo.dwMajorType)
                {
                    //TypeMap.AlarmMinorTypeMap(struFileInfo, csTmp);
                }
                else if (CHCNetSDK.MAJOR_OPERATION == struFileInfo.dwMajorType)
                {
                    //TypeMap.OperationMinorTypeMap(struFileInfo, csTmp);
                }
                else if (CHCNetSDK.MAJOR_EXCEPTION == struFileInfo.dwMajorType)
                {
                    //TypeMap.ExceptionMinorTypeMap(struFileInfo, csTmp);
                }
                else if (CHCNetSDK.MAJOR_EVENT == struFileInfo.dwMajorType)
                {
                    EventMinorTypeMap(struFileInfo, csTmp);
                }

                String szInfo = new String(csTmp).TrimEnd('\0');//验证方式及结果
                String szInfoBuf = null;
                szInfoBuf = szInfo;
                /**************************************************/
                String name = System.Text.Encoding.UTF8.GetString(struAcsAlarmInfo.sNetUser).TrimEnd('\0');
                for (int i = 0; i < struAcsAlarmInfo.sNetUser.Length; i++)
                {
                    if (struAcsAlarmInfo.sNetUser[i] == 0)
                    {
                        name = name.Substring(0, i);
                        break;
                    }
                }
                /**************************************************/
                string szdatetime = struAcsAlarmInfo.struTime.dwYear + "-" + struAcsAlarmInfo.struTime.dwMonth + "-"
                    + struAcsAlarmInfo.struTime.dwDay + " " + struAcsAlarmInfo.struTime.dwHour + ":"
                    + struAcsAlarmInfo.struTime.dwMinute + ":" + struAcsAlarmInfo.struTime.dwSecond;
                szInfoBuf = string.Format("{0} time:{1,4}-{2:D2}-{3} {4:D2}:{5:D2}:{6:D2}, [{7}]({8})", szInfo, struAcsAlarmInfo.struTime.dwYear, struAcsAlarmInfo.struTime.dwMonth,
                    struAcsAlarmInfo.struTime.dwDay, struAcsAlarmInfo.struTime.dwHour, struAcsAlarmInfo.struTime.dwMinute, struAcsAlarmInfo.struTime.dwSecond,
                    struAcsAlarmInfo.struRemoteHostAddr.sIpV4, name);//获取时间和设备IP

                String CardNO = string.Empty;
                if (struAcsAlarmInfo.struAcsEventInfo.byCardNo[0] != 0)
                {
                    CardNO = System.Text.Encoding.UTF8.GetString(struAcsAlarmInfo.struAcsEventInfo.byCardNo).TrimEnd('\0');
                    szInfoBuf = szInfoBuf + "+Card Number:" + CardNO;
                }
                String[] szCardType = { "normal card", "disabled card", "blacklist card", "night watch card", "stress card", "super card", "guest card" };
                byte byCardType = struAcsAlarmInfo.struAcsEventInfo.byCardType;


                string EmployeeNoStr = string.Empty;
                if (struAcsAlarmInfo.byAcsEventInfoExtend != 0 && struAcsAlarmInfo.pAcsEventInfoExtend != null)
                {
                    //Parse Employee No
                    CHCNetSDK.NET_DVR_ACS_EVENT_INFO_EXTEND struExtendEventInfo = (CHCNetSDK.NET_DVR_ACS_EVENT_INFO_EXTEND)Marshal.PtrToStructure(struAcsAlarmInfo.pAcsEventInfoExtend, typeof(CHCNetSDK.NET_DVR_ACS_EVENT_INFO_EXTEND));
                    if (struExtendEventInfo.byEmployeeNo.Length != 0)
                    {
                        EmployeeNoStr = System.Text.Encoding.Default.GetString(struExtendEventInfo.byEmployeeNo).Replace("\0", "");
                        if (EmployeeNoStr == "" || EmployeeNoStr == null)
                        {
                            szInfoBuf = szInfoBuf + " EmployeeNo: none";
                        }
                        else
                        {
                            szInfoBuf = szInfoBuf + " EmployeeNo:" + EmployeeNoStr;
                        }

                    }
                    else
                    {
                        szInfoBuf = szInfoBuf + " EmployeeNo: none";
                    }
                    //0-undefined, 1-checkIn, 2-checkOut, 3-breakOut, 4-breakIn, 5-overtimeIn, 6-overtimeOut 
                    //增加考勤状态值的解析
                    //if (struExtendEventInfo.byStatusValue == 0)
                    //{
                    //    szInfoBuf = szInfoBuf + "Status:  undefined";
                    //}
                    //else if (struExtendEventInfo.byStatusValue == 1)
                    //{
                    //    szInfoBuf = szInfoBuf + "Status:  checkIn";
                    //}
                    //else if (struExtendEventInfo.byStatusValue == 2)
                    //{
                    //    szInfoBuf = szInfoBuf + "Status:  breakOut";
                    //}
                    //else if (struExtendEventInfo.byStatusValue == 3)
                    //{
                    //    szInfoBuf = szInfoBuf + "Status: breakOut";
                    //}
                    //else if (struExtendEventInfo.byStatusValue == 4)
                    //{
                    //    szInfoBuf = szInfoBuf + "Status: breakIn";
                    //}
                    //else if (struExtendEventInfo.byStatusValue == 5)
                    //{
                    //    szInfoBuf = szInfoBuf + "Status: overtimeIn";
                    //}
                    //else if (struExtendEventInfo.byStatusValue == 6)
                    //{
                    //    szInfoBuf = szInfoBuf + "Status: overtimeOut";
                    //}
                }
                else
                {
                    EmployeeNoStr = struAcsAlarmInfo.struAcsEventInfo.dwEmployeeNo + " ";
                    szInfoBuf = szInfoBuf + " EmployeeNo: " + EmployeeNoStr;
                }
                if (szInfo != "")
                {
                    BuferRecord(pAlarmer.sDeviceIP, szInfo, CardNO, EmployeeNoStr, szdatetime);//20211027

                }
                //if (byCardType != 0 && byCardType <= szCardType.Length)
                //{
                //    szInfoBuf = szInfoBuf + "+Card Type:" + szCardType[byCardType - 1];
                //}

                //if (struAcsAlarmInfo.struAcsEventInfo.dwCardReaderNo != 0)
                //{
                //    szInfoBuf = szInfoBuf + "+Card Reader Number:" + struAcsAlarmInfo.struAcsEventInfo.dwCardReaderNo;
                //}
                //if (struAcsAlarmInfo.struAcsEventInfo.dwDoorNo != 0)
                //{
                //    szInfoBuf = szInfoBuf + "+Door Number:" + struAcsAlarmInfo.struAcsEventInfo.dwDoorNo;
                //}
                //if (struAcsAlarmInfo.struAcsEventInfo.dwVerifyNo != 0)
                //{
                //    szInfoBuf = szInfoBuf + "+Multiple Card Authentication Serial Number:" + struAcsAlarmInfo.struAcsEventInfo.dwVerifyNo;
                //}
                //if (struAcsAlarmInfo.struAcsEventInfo.dwAlarmInNo != 0)
                //{
                //    szInfoBuf = szInfoBuf + "+Alarm Input Number:" + struAcsAlarmInfo.struAcsEventInfo.dwAlarmInNo;
                //}
                //if (struAcsAlarmInfo.struAcsEventInfo.dwAlarmOutNo != 0)
                //{
                //    szInfoBuf = szInfoBuf + "+Alarm Output Number:" + struAcsAlarmInfo.struAcsEventInfo.dwAlarmOutNo;
                //}
                //if (struAcsAlarmInfo.struAcsEventInfo.dwCaseSensorNo != 0)
                //{
                //    szInfoBuf = szInfoBuf + "+Event Trigger Number:" + struAcsAlarmInfo.struAcsEventInfo.dwCaseSensorNo;
                //}
                //if (struAcsAlarmInfo.struAcsEventInfo.dwRs485No != 0)
                //{
                //    szInfoBuf = szInfoBuf + "+RS485 Channel Number:" + struAcsAlarmInfo.struAcsEventInfo.dwRs485No;
                //}
                //if (struAcsAlarmInfo.struAcsEventInfo.dwMultiCardGroupNo != 0)
                //{
                //    szInfoBuf = szInfoBuf + "+Multi Recombinant Authentication ID:" + struAcsAlarmInfo.struAcsEventInfo.dwMultiCardGroupNo;
                //}
                //if (struAcsAlarmInfo.struAcsEventInfo.byCardReaderKind != 0)
                //{
                //    szInfoBuf = szInfoBuf + "+CardReaderKind:" + struAcsAlarmInfo.struAcsEventInfo.byCardReaderKind.ToString();
                //}
                //if (struAcsAlarmInfo.struAcsEventInfo.wAccessChannel >= 0)
                //{
                //    szInfoBuf = szInfoBuf + "+wAccessChannel:" + struAcsAlarmInfo.struAcsEventInfo.wAccessChannel;
                //}
                ////////if (struAcsAlarmInfo.struAcsEventInfo.dwEmployeeNo != 0)
                ////////{
                ////////    szInfoBuf = szInfoBuf + "+EmployeeNo:" + struAcsAlarmInfo.struAcsEventInfo.dwEmployeeNo + "IP:" + pAlarmer.sDeviceIP;//获取工号
                ////////    //增加事件记录处理
                ////////    //BuferRecord(pAlarmer.sDeviceIP, szInfo, struAcsAlarmInfo.struAcsEventInfo.dwEmployeeNo.ToString(), szdatetime);//20211027
                ////////}
                //if (struAcsAlarmInfo.struAcsEventInfo.byDeviceNo != 0)
                //{
                //    szInfoBuf = szInfoBuf + "+byDeviceNo:" + struAcsAlarmInfo.struAcsEventInfo.byDeviceNo.ToString();
                //}
                //if (struAcsAlarmInfo.struAcsEventInfo.wLocalControllerID >= 0)
                //{
                //    szInfoBuf = szInfoBuf + "+wLocalControllerID:" + struAcsAlarmInfo.struAcsEventInfo.wLocalControllerID;
                //}
                //if (struAcsAlarmInfo.struAcsEventInfo.byInternetAccess >= 0)
                //{
                //    szInfoBuf = szInfoBuf + "+byInternetAccess:" + struAcsAlarmInfo.struAcsEventInfo.byInternetAccess.ToString();
                //}
                //////if (struAcsAlarmInfo.struAcsEventInfo.byType >= 0)
                //////{
                //////    szInfoBuf = szInfoBuf + "+byType:" + struAcsAlarmInfo.struAcsEventInfo.byType.ToString();
                //////}
                //if (struAcsAlarmInfo.struAcsEventInfo.bySwipeCardType != 0)
                //{
                //    szInfoBuf = szInfoBuf + "+bySwipeCardType:" + struAcsAlarmInfo.struAcsEventInfo.bySwipeCardType.ToString();
                //}
                //其它消息先不罗列了......

                //if (struAcsAlarmInfo.dwPicDataLen > 0)//保存人脸照片
                //{
                //    path = null;
                //    Random rand = new Random(unchecked((int)DateTime.Now.Ticks));
                //    path = string.Format(@"C:/Picture/ACS_LocalTime{0}_{1}.bmp", szInfo, rand.Next());
                //    using (FileStream fs = new FileStream(path, FileMode.Create))
                //    {
                //        int iLen = (int)struAcsAlarmInfo.dwPicDataLen;
                //        byte[] by = new byte[iLen];
                //        Marshal.Copy(struAcsAlarmInfo.pPicData, by, 0, iLen);
                //        fs.Write(by, 0, iLen);
                //        fs.Close();
                //    }
                //    szInfoBuf = szInfoBuf + "SavePath:" + path;
                //}

                //this.listViewAlarmInfo.BeginInvoke(new Action(() =>
                //{
                //    ListViewItem Item = new ListViewItem();
                //    Item.Text = (++m_lLogNum).ToString();
                //    Item.SubItems.Add(DateTime.Now.ToString());
                //    Item.SubItems.Add(szInfoBuf);
                //    this.listViewAlarmInfo.Items.Add(Item);
                //}));
            }
            catch(Exception ex)
            {

            }

        }

        void EventMinorTypeMap(CHCNetSDK.NET_DVR_LOG_V30 stLogInfo, char[] csTmp)
        {
            String szTemp = null;
            switch (stLogInfo.dwMinorType)
            {
                case CHCNetSDK.MINOR_LEGAL_CARD_PASS:
                    szTemp = String.Format("MINOR_LEGAL_CARD_PASS");//卡验证成功
                    break;
                //case CHCNetSDK.MINOR_CARD_AND_PSW_PASS:
                //    szTemp = String.Format("MINOR_CARD_AND_PSW_PASS");
                //    break;
                //case CHCNetSDK.MINOR_CARD_AND_PSW_FAIL:
                //    szTemp = String.Format("MINOR_CARD_AND_PSW_FAIL");
                //    break;
                //case CHCNetSDK.MINOR_CARD_AND_PSW_TIMEOUT:
                //    szTemp = String.Format("MINOR_CARD_AND_PSW_TIMEOUT");
                //    break;
                //case CHCNetSDK.MINOR_CARD_AND_PSW_OVER_TIME:
                //    szTemp = String.Format("MINOR_CARD_AND_PSW_OVER_TIME");
                //    break;
                //case CHCNetSDK.MINOR_CARD_NO_RIGHT:
                //    szTemp = String.Format("MINOR_CARD_NO_RIGHT");
                //    break;
                //case CHCNetSDK.MINOR_CARD_INVALID_PERIOD:
                //    szTemp = String.Format("MINOR_CARD_INVALID_PERIOD");
                //    break;
                //case CHCNetSDK.MINOR_CARD_OUT_OF_DATE:
                //    szTemp = String.Format("MINOR_CARD_OUT_OF_DATE");
                //    break;
                case CHCNetSDK.MINOR_INVALID_CARD:
                    szTemp = String.Format("MINOR_INVALID_CARD");//卡验证失败
                    break;
                //case CHCNetSDK.MINOR_ANTI_SNEAK_FAIL:
                //    szTemp = String.Format("MINOR_ANTI_SNEAK_FAIL");
                //    break;
                //case CHCNetSDK.MINOR_INTERLOCK_DOOR_NOT_CLOSE:
                //    szTemp = String.Format("MINOR_INTERLOCK_DOOR_NOT_CLOSE");
                //    break;
                //case CHCNetSDK.MINOR_NOT_BELONG_MULTI_GROUP:
                //    szTemp = String.Format("MINOR_NOT_BELONG_MULTI_GROUP");
                //    break;
                //case CHCNetSDK.MINOR_INVALID_MULTI_VERIFY_PERIOD:
                //    szTemp = String.Format("MINOR_INVALID_MULTI_VERIFY_PERIOD");
                //    break;
                //case CHCNetSDK.MINOR_MULTI_VERIFY_SUPER_RIGHT_FAIL:
                //    szTemp = String.Format("MINOR_MULTI_VERIFY_SUPER_RIGHT_FAIL");
                //    break;
                //case CHCNetSDK.MINOR_MULTI_VERIFY_REMOTE_RIGHT_FAIL:
                //    szTemp = String.Format("MINOR_MULTI_VERIFY_REMOTE_RIGHT_FAIL");
                //    break;
                //case CHCNetSDK.MINOR_MULTI_VERIFY_SUCCESS:
                //    szTemp = String.Format("MINOR_MULTI_VERIFY_SUCCESS");
                //    break;
                //case CHCNetSDK.MINOR_LEADER_CARD_OPEN_BEGIN:
                //    szTemp = String.Format("MINOR_LEADER_CARD_OPEN_BEGIN");
                //    break;
                //case CHCNetSDK.MINOR_LEADER_CARD_OPEN_END:
                //    szTemp = String.Format("MINOR_LEADER_CARD_OPEN_END");
                //    break;
                //case CHCNetSDK.MINOR_ALWAYS_OPEN_BEGIN:
                //    szTemp = String.Format("MINOR_ALWAYS_OPEN_BEGIN");
                //    break;
                //case CHCNetSDK.MINOR_ALWAYS_OPEN_END:
                //    szTemp = String.Format("MINOR_ALWAYS_OPEN_END");
                //    break;
                //case CHCNetSDK.MINOR_LOCK_OPEN:
                //    szTemp = String.Format("MINOR_LOCK_OPEN");
                //    break;
                //case CHCNetSDK.MINOR_LOCK_CLOSE:
                //    szTemp = String.Format("MINOR_LOCK_CLOSE");
                //    break;
                //case CHCNetSDK.MINOR_DOOR_BUTTON_PRESS:
                //    szTemp = String.Format("MINOR_DOOR_BUTTON_PRESS");
                //    break;
                //case CHCNetSDK.MINOR_DOOR_BUTTON_RELEASE:
                //    szTemp = String.Format("MINOR_DOOR_BUTTON_RELEASE");
                //    break;
                //case CHCNetSDK.MINOR_DOOR_OPEN_NORMAL:
                //    szTemp = String.Format("MINOR_DOOR_OPEN_NORMAL");
                //    break;
                //case CHCNetSDK.MINOR_DOOR_CLOSE_NORMAL:
                //    szTemp = String.Format("MINOR_DOOR_CLOSE_NORMAL");
                //    break;
                //case CHCNetSDK.MINOR_DOOR_OPEN_ABNORMAL:
                //    szTemp = String.Format("MINOR_DOOR_OPEN_ABNORMAL");
                //    break;
                //case CHCNetSDK.MINOR_DOOR_OPEN_TIMEOUT:
                //    szTemp = String.Format("MINOR_DOOR_OPEN_TIMEOUT");
                //    break;
                //case CHCNetSDK.MINOR_ALARMOUT_ON:
                //    szTemp = String.Format("MINOR_ALARMOUT_ON");
                //    break;
                //case CHCNetSDK.MINOR_ALARMOUT_OFF:
                //    szTemp = String.Format("MINOR_ALARMOUT_OFF");
                //    break;
                //case CHCNetSDK.MINOR_ALWAYS_CLOSE_BEGIN:
                //    szTemp = String.Format("MINOR_ALWAYS_CLOSE_BEGIN");
                //    break;
                //case CHCNetSDK.MINOR_ALWAYS_CLOSE_END:
                //    szTemp = String.Format("MINOR_ALWAYS_CLOSE_END");
                //    break;
                //case CHCNetSDK.MINOR_MULTI_VERIFY_NEED_REMOTE_OPEN:
                //    szTemp = String.Format("MINOR_MULTI_VERIFY_NEED_REMOTE_OPEN");
                //    break;
                //case CHCNetSDK.MINOR_MULTI_VERIFY_SUPERPASSWD_VERIFY_SUCCESS:
                //    szTemp = String.Format("MINOR_MULTI_VERIFY_SUPERPASSWD_VERIFY_SUCCESS");
                //    break;
                //case CHCNetSDK.MINOR_MULTI_VERIFY_REPEAT_VERIFY:
                //    szTemp = String.Format("MINOR_MULTI_VERIFY_REPEAT_VERIFY");
                //    break;
                //case CHCNetSDK.MINOR_MULTI_VERIFY_TIMEOUT:
                //    szTemp = String.Format("MINOR_MULTI_VERIFY_TIMEOUT");
                //    break;
                //case CHCNetSDK.MINOR_DOORBELL_RINGING:
                //    szTemp = String.Format("MINOR_DOORBELL_RINGING");
                //    break;
                //case CHCNetSDK.MINOR_FINGERPRINT_COMPARE_PASS:
                //    szTemp = String.Format("MINOR_FINGERPRINT_COMPARE_PASS");
                //    break;
                //case CHCNetSDK.MINOR_FINGERPRINT_COMPARE_FAIL:
                //    szTemp = String.Format("MINOR_FINGERPRINT_COMPARE_FAIL");
                //    break;
                //case CHCNetSDK.MINOR_CARD_FINGERPRINT_VERIFY_PASS:
                //    szTemp = String.Format("MINOR_CARD_FINGERPRINT_VERIFY_PASS");
                //    break;
                //case CHCNetSDK.MINOR_CARD_FINGERPRINT_VERIFY_FAIL:
                //    szTemp = String.Format("MINOR_CARD_FINGERPRINT_VERIFY_FAIL");
                //    break;
                //case CHCNetSDK.MINOR_CARD_FINGERPRINT_VERIFY_TIMEOUT:
                //    szTemp = String.Format("MINOR_CARD_FINGERPRINT_VERIFY_TIMEOUT");
                //    break;
                //case CHCNetSDK.MINOR_CARD_FINGERPRINT_PASSWD_VERIFY_PASS:
                //    szTemp = String.Format("MINOR_CARD_FINGERPRINT_PASSWD_VERIFY_PASS");
                //    break;
                //case CHCNetSDK.MINOR_CARD_FINGERPRINT_PASSWD_VERIFY_FAIL:
                //    szTemp = String.Format("MINOR_CARD_FINGERPRINT_PASSWD_VERIFY_FAIL");
                //    break;
                //case CHCNetSDK.MINOR_CARD_FINGERPRINT_PASSWD_VERIFY_TIMEOUT:
                //    szTemp = String.Format("MINOR_CARD_FINGERPRINT_PASSWD_VERIFY_TIMEOUT");
                //    break;
                //case CHCNetSDK.MINOR_FINGERPRINT_PASSWD_VERIFY_PASS:
                //    szTemp = String.Format("MINOR_FINGERPRINT_PASSWD_VERIFY_PASS");
                //    break;
                //case CHCNetSDK.MINOR_FINGERPRINT_PASSWD_VERIFY_FAIL:
                //    szTemp = String.Format("MINOR_FINGERPRINT_PASSWD_VERIFY_FAIL");
                //    break;
                //case CHCNetSDK.MINOR_FINGERPRINT_PASSWD_VERIFY_TIMEOUT:
                //    szTemp = String.Format("MINOR_FINGERPRINT_PASSWD_VERIFY_TIMEOUT");
                //    break;
                //case CHCNetSDK.MINOR_FINGERPRINT_INEXISTENCE:
                //    szTemp = String.Format("MINOR_FINGERPRINT_INEXISTENCE");
                //    break;
                //case CHCNetSDK.MINOR_CARD_PLATFORM_VERIFY:
                //    szTemp = String.Format("MINOR_CARD_PLATFORM_VERIFY");
                //    break;
                //case CHCNetSDK.MINOR_CALL_CENTER:
                //    szTemp = String.Format("MINOR_CALL_CENTER");
                //    break;
                //case CHCNetSDK.MINOR_FIRE_RELAY_TURN_ON_DOOR_ALWAYS_OPEN:
                //    szTemp = String.Format("MINOR_FIRE_RELAY_TURN_ON_DOOR_ALWAYS_OPEN");
                //    break;
                //case CHCNetSDK.MINOR_FIRE_RELAY_RECOVER_DOOR_RECOVER_NORMAL:
                //    szTemp = String.Format("MINOR_FIRE_RELAY_RECOVER_DOOR_RECOVER_NORMAL");
                //    break;
                //case CHCNetSDK.MINOR_FACE_AND_FP_VERIFY_PASS:
                //    szTemp = String.Format("MINOR_FACE_AND_FP_VERIFY_PASS");
                //    break;
                //case CHCNetSDK.MINOR_FACE_AND_FP_VERIFY_FAIL:
                //    szTemp = String.Format("MINOR_FACE_AND_FP_VERIFY_FAIL");
                //    break;
                //case CHCNetSDK.MINOR_FACE_AND_FP_VERIFY_TIMEOUT:
                //    szTemp = String.Format("MINOR_FACE_AND_FP_VERIFY_TIMEOUT");
                //    break;
                //case CHCNetSDK.MINOR_FACE_AND_PW_VERIFY_PASS:
                //    szTemp = String.Format("MINOR_FACE_AND_PW_VERIFY_PASS");
                //    break;
                //case CHCNetSDK.MINOR_FACE_AND_PW_VERIFY_FAIL:
                //    szTemp = String.Format("MINOR_FACE_AND_PW_VERIFY_FAIL");
                //    break;
                //case CHCNetSDK.MINOR_FACE_AND_PW_VERIFY_TIMEOUT:
                //    szTemp = String.Format("MINOR_FACE_AND_PW_VERIFY_TIMEOUT");
                //    break;
                //case CHCNetSDK.MINOR_FACE_AND_CARD_VERIFY_PASS:
                //    szTemp = String.Format("MINOR_FACE_AND_CARD_VERIFY_PASS");
                //    break;
                //case CHCNetSDK.MINOR_FACE_AND_CARD_VERIFY_FAIL:
                //    szTemp = String.Format("MINOR_FACE_AND_CARD_VERIFY_FAIL");
                //    break;
                //case CHCNetSDK.MINOR_FACE_AND_CARD_VERIFY_TIMEOUT:
                //    szTemp = String.Format("MINOR_FACE_AND_CARD_VERIFY_TIMEOUT");
                //    break;
                //case CHCNetSDK.MINOR_FACE_AND_PW_AND_FP_VERIFY_PASS:
                //    szTemp = String.Format("MINOR_FACE_AND_PW_AND_FP_VERIFY_PASS");
                //    break;
                //case CHCNetSDK.MINOR_FACE_AND_PW_AND_FP_VERIFY_FAIL:
                //    szTemp = String.Format("MINOR_FACE_AND_PW_AND_FP_VERIFY_FAIL");
                //    break;
                //case CHCNetSDK.MINOR_FACE_AND_PW_AND_FP_VERIFY_TIMEOUT:
                //    szTemp = String.Format("MINOR_FACE_AND_PW_AND_FP_VERIFY_TIMEOUT");
                //    break;
                //case CHCNetSDK.MINOR_FACE_CARD_AND_FP_VERIFY_PASS:
                //    szTemp = String.Format("MINOR_FACE_CARD_AND_FP_VERIFY_PASS");
                //    break;
                //case CHCNetSDK.MINOR_FACE_CARD_AND_FP_VERIFY_FAIL:
                //    szTemp = String.Format("MINOR_FACE_CARD_AND_FP_VERIFY_FAIL");
                //    break;
                //case CHCNetSDK.MINOR_FACE_CARD_AND_FP_VERIFY_TIMEOUT:
                //    szTemp = String.Format("MINOR_FACE_CARD_AND_FP_VERIFY_TIMEOUT");
                //    break;
                //case CHCNetSDK.MINOR_EMPLOYEENO_AND_FP_VERIFY_PASS:
                //    szTemp = String.Format("MINOR_EMPLOYEENO_AND_FP_VERIFY_PASS");
                //    break;
                //case CHCNetSDK.MINOR_EMPLOYEENO_AND_FP_VERIFY_FAIL:
                //    szTemp = String.Format("MINOR_EMPLOYEENO_AND_FP_VERIFY_FAIL");
                //    break;
                //case CHCNetSDK.MINOR_EMPLOYEENO_AND_FP_VERIFY_TIMEOUT:
                //    szTemp = String.Format("MINOR_EMPLOYEENO_AND_FP_VERIFY_TIMEOUT");
                //    break;
                //case CHCNetSDK.MINOR_EMPLOYEENO_AND_FP_AND_PW_VERIFY_PASS:
                //    szTemp = String.Format("MINOR_EMPLOYEENO_AND_FP_AND_PW_VERIFY_PASS");
                //    break;
                //case CHCNetSDK.MINOR_EMPLOYEENO_AND_FP_AND_PW_VERIFY_FAIL:
                //    szTemp = String.Format("MINOR_EMPLOYEENO_AND_FP_AND_PW_VERIFY_FAIL");
                //    break;
                //case CHCNetSDK.MINOR_EMPLOYEENO_AND_FP_AND_PW_VERIFY_TIMEOUT:
                //    szTemp = String.Format("MINOR_EMPLOYEENO_AND_FP_AND_PW_VERIFY_TIMEOUT");
                //    break;
                case CHCNetSDK.MINOR_FACE_VERIFY_PASS:
                    szTemp = String.Format("MINOR_FACE_VERIFY_PASS");//人脸验证成功
                    break;
                case CHCNetSDK.MINOR_FACE_VERIFY_FAIL:
                    szTemp = String.Format("MINOR_FACE_VERIFY_FAIL");//人脸验证失败
                    break;
                //case CHCNetSDK.MINOR_EMPLOYEENO_AND_FACE_VERIFY_PASS:
                //    szTemp = String.Format("MINOR_EMPLOYEENO_AND_FACE_VERIFY_PASS");
                //    break;
                //case CHCNetSDK.MINOR_EMPLOYEENO_AND_FACE_VERIFY_FAIL:
                //    szTemp = String.Format("MINOR_EMPLOYEENO_AND_FACE_VERIFY_FAIL");
                //    break;
                //case CHCNetSDK.MINOR_EMPLOYEENO_AND_FACE_VERIFY_TIMEOUT:
                //    szTemp = String.Format("MINOR_EMPLOYEENO_AND_FACE_VERIFY_TIMEOUT");
                //    break;
                //case CHCNetSDK.MINOR_FACE_RECOGNIZE_FAIL:
                //    szTemp = String.Format("MINOR_FACE_RECOGNIZE_FAIL");
                //    break;
                //case CHCNetSDK.MINOR_FIRSTCARD_AUTHORIZE_BEGIN:
                //    szTemp = String.Format("MINOR_FIRSTCARD_AUTHORIZE_BEGIN");
                //    break;
                //case CHCNetSDK.MINOR_FIRSTCARD_AUTHORIZE_END:
                //    szTemp = String.Format("MINOR_FIRSTCARD_AUTHORIZE_END");
                //    break;
                //case CHCNetSDK.MINOR_DOORLOCK_INPUT_SHORT_CIRCUIT:
                //    szTemp = String.Format("MINOR_DOORLOCK_INPUT_SHORT_CIRCUIT");
                //    break;
                //case CHCNetSDK.MINOR_DOORLOCK_INPUT_BROKEN_CIRCUIT:
                //    szTemp = String.Format("MINOR_DOORLOCK_INPUT_BROKEN_CIRCUIT");
                //    break;
                //case CHCNetSDK.MINOR_DOORLOCK_INPUT_EXCEPTION:
                //    szTemp = String.Format("MINOR_DOORLOCK_INPUT_EXCEPTION");
                //    break;
                //case CHCNetSDK.MINOR_DOORCONTACT_INPUT_SHORT_CIRCUIT:
                //    szTemp = String.Format("MINOR_DOORCONTACT_INPUT_SHORT_CIRCUIT");
                //    break;
                //case CHCNetSDK.MINOR_DOORCONTACT_INPUT_BROKEN_CIRCUIT:
                //    szTemp = String.Format("MINOR_DOORCONTACT_INPUT_BROKEN_CIRCUIT");
                //    break;
                //case CHCNetSDK.MINOR_DOORCONTACT_INPUT_EXCEPTION:
                //    szTemp = String.Format("MINOR_DOORCONTACT_INPUT_EXCEPTION");
                //    break;
                //case CHCNetSDK.MINOR_OPENBUTTON_INPUT_SHORT_CIRCUIT:
                //    szTemp = String.Format("MINOR_OPENBUTTON_INPUT_SHORT_CIRCUIT");
                //    break;
                //case CHCNetSDK.MINOR_OPENBUTTON_INPUT_BROKEN_CIRCUIT:
                //    szTemp = String.Format("MINOR_OPENBUTTON_INPUT_BROKEN_CIRCUIT");
                //    break;
                //case CHCNetSDK.MINOR_OPENBUTTON_INPUT_EXCEPTION:
                //    szTemp = String.Format("MINOR_OPENBUTTON_INPUT_EXCEPTION");
                //    break;
                //case CHCNetSDK.MINOR_DOORLOCK_OPEN_EXCEPTION:
                //    szTemp = String.Format("MINOR_DOORLOCK_OPEN_EXCEPTION");
                //    break;
                //case CHCNetSDK.MINOR_DOORLOCK_OPEN_TIMEOUT:
                //    szTemp = String.Format("MINOR_DOORLOCK_OPEN_TIMEOUT");
                //    break;
                //case CHCNetSDK.MINOR_FIRSTCARD_OPEN_WITHOUT_AUTHORIZE:
                //    szTemp = String.Format("MINOR_FIRSTCARD_OPEN_WITHOUT_AUTHORIZE");
                //    break;
                //case CHCNetSDK.MINOR_CALL_LADDER_RELAY_BREAK:
                //    szTemp = String.Format("MINOR_CALL_LADDER_RELAY_BREAK");
                //    break;
                //case CHCNetSDK.MINOR_CALL_LADDER_RELAY_CLOSE:
                //    szTemp = String.Format("MINOR_CALL_LADDER_RELAY_CLOSE");
                //    break;
                //case CHCNetSDK.MINOR_AUTO_KEY_RELAY_BREAK:
                //    szTemp = String.Format("MINOR_AUTO_KEY_RELAY_BREAK");
                //    break;
                //case CHCNetSDK.MINOR_AUTO_KEY_RELAY_CLOSE:
                //    szTemp = String.Format("MINOR_AUTO_KEY_RELAY_CLOSE");
                //    break;
                //case CHCNetSDK.MINOR_KEY_CONTROL_RELAY_BREAK:
                //    szTemp = String.Format("MINOR_KEY_CONTROL_RELAY_BREAK");
                //    break;
                //case CHCNetSDK.MINOR_KEY_CONTROL_RELAY_CLOSE:
                //    szTemp = String.Format("MINOR_KEY_CONTROL_RELAY_CLOSE");
                //    break;
                //case CHCNetSDK.MINOR_EMPLOYEENO_AND_PW_PASS:
                //    szTemp = String.Format("MINOR_EMPLOYEENO_AND_PW_PASS");
                //    break;
                //case CHCNetSDK.MINOR_EMPLOYEENO_AND_PW_FAIL:
                //    szTemp = String.Format("MINOR_EMPLOYEENO_AND_PW_FAIL");
                //    break;
                //case CHCNetSDK.MINOR_EMPLOYEENO_AND_PW_TIMEOUT:
                //    szTemp = String.Format("MINOR_EMPLOYEENO_AND_PW_TIMEOUT");
                //    break;
                //case CHCNetSDK.MINOR_HUMAN_DETECT_FAIL:
                //    szTemp = String.Format("MINOR_HUMAN_DETECT_FAIL");
                //    break;
                //case CHCNetSDK.MINOR_PEOPLE_AND_ID_CARD_COMPARE_PASS:
                //    szTemp = String.Format("MINOR_PEOPLE_AND_ID_CARD_COMPARE_PASS");
                //    break;
                //case CHCNetSDK.MINOR_PEOPLE_AND_ID_CARD_COMPARE_FAIL:
                //    szTemp = String.Format("MINOR_PEOPLE_AND_ID_CARD_COMPARE_FAIL");
                //    break;
                //case CHCNetSDK.MINOR_CERTIFICATE_BLACK_LIST:
                //    szTemp = String.Format("MINOR_CERTIFICATE_BLACK_LIST");
                //    break;
                //case CHCNetSDK.MINOR_LEGAL_MESSAGE:
                //    szTemp = String.Format("MINOR_LEGAL_MESSAGE");
                //    break;
                //case CHCNetSDK.MINOR_ILLEGAL_MESSAGE:
                //    szTemp = String.Format("MINOR_ILLEGAL_MESSAGE");
                //    break;
                //case CHCNetSDK.MINOR_MAC_DETECT:
                //    szTemp = String.Format("MINOR_MAC_DETECT");
                //    break;
                default:
                    //szTemp = String.Format("Main Event unknown:" + "0x" + "stLogInfo.dwMinorType");
                    szTemp = "";
                    break;
            }
            szTemp.CopyTo(0, csTmp, 0, szTemp.Length);
            return;
        }
        public bool GetAcsWorkStatus(int m_lUserID, ref CHCNetSDK.NET_DVR_ACS_WORK_STATUS_V50 struAcsWorkStatus)
        {
            //struAcsWorkStatus.Init();
            //CHCNetSDK.NET_DVR_ACS_PARAM_TYPE struAcsParam = new CHCNetSDK.NET_DVR_ACS_PARAM_TYPE();
            //struAcsParam.dwSize = (uint)Marshal.SizeOf(struAcsParam);
            //struAcsParam.dwParamType |= 1 << 12;

            //uint dwSize = (uint)Marshal.SizeOf(struAcsParam);
            //IntPtr ptrAcsParam = Marshal.AllocHGlobal((int)dwSize);
            //Marshal.StructureToPtr(struAcsParam, ptrAcsParam, false);
            //bool bl = CHCNetSDK.NET_DVR_RemoteControl(m_lUserID, CHCNetSDK.NET_DVR_CLEAR_ACS_PARAM, ptrAcsParam, dwSize);//设备状态监测TRUE=在线
            //return bl;
            uint dwReturned = 0;
            uint dwSize = (uint)Marshal.SizeOf(struAcsWorkStatus);
            struAcsWorkStatus.dwSize = dwSize;
            IntPtr ptrAcsWorkStatus = Marshal.AllocHGlobal((Int32)dwSize);
            Marshal.StructureToPtr(struAcsWorkStatus, ptrAcsWorkStatus, false);

            if (!CHCNetSDK.NET_DVR_GetDVRConfig(m_lUserID, CHCNetSDK.NET_DVR_GET_ACS_WORK_STATUS_V50, 0, ptrAcsWorkStatus, dwSize, ref dwReturned))
            {
                return false;
            }
            else
            {
                return true;
            }
        }
        public void BuferRecord(string sDeviceIP, string szInfo, string CardNO, string dwEmployeeNo, string szdatetime)
        {
            try
            {
                string result = "";
                string type = "";
                switch (szInfo)
                {
                    case "MINOR_LEGAL_CARD_PASS"://卡验证成功
                                                 // 增加事件记录处理
                        type = "刷卡/二维码";
                        result = "成功";
                        break;
                    //case "MINOR_INVALID_CARD"://卡验证失败
                    //    type = "刷卡/二维码";
                    //    result = "失败";
                    //    break;
                    case "MINOR_FACE_VERIFY_PASS"://人脸验证成功
                        type = "人脸";
                        result = "成功";
                        break;
                        //case "MINOR_FACE_VERIFY_FAIL"://人脸验证失败
                        //    type = "人脸";
                        //    result = "失败";
                        //    break;
                }
                if (result != "")
                {
                    RecordDAL da = new RecordDAL();
                    DataAnalysisBUS bUS = new DataAnalysisBUS();
                    string cmd;
                    bUS.SendToDevice(sDeviceIP, dwEmployeeNo, out cmd);
                    //da.InsertLadderRecordFromHK(sDeviceIP, type, dwEmployeeNo, szdatetime, result, cmd);

                }

                //根据IP找到devid,根据dwEmployeeNo找到ownerid,根据szInfo解析验证方式及结果，根据szdatetime获取验证时间
                //Database myconnstr = new Database();
                //myconn = new MySqlConnection(myconnstr.myconnstr);
                //DataSet myds = new DataSet();
                //try
                //{
                //    myconn.Open();
                //    String mysqlstr = "select * from vi_voucher_info where USERID='" + dwEmployeeNo + "' and Dev_IP='" + sDeviceIP + "'";
                //    MySqlDataAdapter myMda = new MySqlDataAdapter(mysqlstr, myconn);
                //    myMda.Fill(myds, "vi_voucher_info");
                //    int Rcount = myds.Tables[0].Rows.Count;
                //    if (Rcount > 0)
                //    {
                //        VoucherRecord vr = new VoucherRecord();
                //        //int ownerid = Convert.ToInt32(myds.Tables[0].Rows[0]["ownerid"].ToString());
                //        //int devid = Convert.ToInt32(myds.Tables[0].Rows[0]["devid"].ToString());
                //        vr.name = myds.Tables[0].Rows[0]["name"].ToString();//业主姓名
                //        vr.building_name = myds.Tables[0].Rows[0]["building_name"].ToString();//单元楼栋
                //        vr.RoomName = myds.Tables[0].Rows[0]["RoomName"].ToString();//房间号
                //        vr.DevNO = myds.Tables[0].Rows[0]["DevNO"].ToString();//设备编码
                //        vr.DevName = myds.Tables[0].Rows[0]["DevName"].ToString();//设备名称

                //        string szTemptype;//认证方式1=刷卡；2=人脸；3=指纹；4=密码
                //        string szTempresult;//认证结果0=失败，1=成功
                //        switch (szInfo)
                //        {
                //            case "MINOR_LEGAL_CARD_PASS":
                //                szTemptype = "刷卡";//卡验证成功
                //                szTempresult = "成功";
                //                break;
                //            case "MINOR_INVALID_CARD":
                //                szTemptype = "刷卡";//卡验证失败
                //                szTempresult = "失败";
                //                break;
                //            case "MINOR_FACE_VERIFY_PASS":
                //                szTemptype = "人脸";//人脸验证成功
                //                szTempresult = "成功";
                //                break;
                //            case "MINOR_FACE_VERIFY_FAIL":
                //                szTemptype = "人脸";//人脸验证失败
                //                szTempresult = "失败";
                //                break;
                //            default:
                //                szTemptype = "";//无验证
                //                szTempresult = "";
                //                break;
                //        }
                //        myconn.Close();
                //        //插入新记录
                //        mysqlstr = "INSERT INTO voucher_record  (name,building_name,Roomname,Dev_IP,DevNO,DevName,AuthorizedType,Authorized_time,Authorized_result) VALUES ('"
                //        + vr.name + "','" + vr.building_name + "','" + vr.RoomName + "','" + sDeviceIP + "','"
                //        + vr.DevNO + "','" + vr.DevName + "','" + szTemptype + "','" + szdatetime + "','" + szTempresult + "')";
                //        DB.InsertTableData(mysqlstr);

                //    }

                //}
                //catch (Exception e)
                //{
                //    return;
                //}
            }
            catch (Exception ex)
            {

            }
        }

    }
}
